package com.xysd.express.activity.main;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.xysd.express.R;
import com.xysd.express.activity.logistics.LogisticsActivity;
import com.xysd.express.base.BottomTabBaseActivity;
import com.xysd.express.fragment.CompanyFragment;
import com.xysd.express.fragment.HomeFragment;
import com.xysd.express.fragment.MineFragment;
import com.xysd.express.fragment.OrderFragment;
import com.xysd.express.widget.BottomTabView;

import org.xutils.view.annotation.ContentView;

import java.util.ArrayList;
import java.util.List;

@ContentView(R.layout.activity_main)
public class MainActivity extends BottomTabBaseActivity {

    List<Fragment> fragments;//Kotlin开发环境
    List<BottomTabView.TabItemView> tabItemViews;
    HomeFragment homeFragment;
    OrderFragment orderFragment;
    CompanyFragment companyFragment;
    MineFragment mineFragment;

    @Override
    protected void init() {

    }

    @Override
    protected List<BottomTabView.TabItemView> getTabViews() {
        tabItemViews = new ArrayList<>();
        BottomTabView.TabItemView tabHome = new BottomTabView.TabItemView(this, "首页",
                R.color.gray, R.color.orange, R.mipmap.icon_home, R.mipmap.icon_home_s);
        BottomTabView.TabItemView tabTender = new BottomTabView.TabItemView(this, "订单",
                R.color.gray, R.color.orange, R.mipmap.icon_order, R.mipmap.icon_order_s);
        BottomTabView.TabItemView tabPublish = new BottomTabView.TabItemView(this, "企业",
                R.color.gray, R.color.orange, R.mipmap.icon_company, R.mipmap.icon_company_s);
        BottomTabView.TabItemView tabMine = new BottomTabView.TabItemView(this, "我的",
                R.color.gray, R.color.orange, R.mipmap.icon_mine, R.mipmap.icon_mine_s);
        tabItemViews.add(tabHome);
        tabItemViews.add(tabTender);
        tabItemViews.add(tabPublish);
        tabItemViews.add(tabMine);
        return tabItemViews;
    }

    @Override
    protected List<Fragment> getFragments() {
        fragments=new ArrayList<>();
        homeFragment=new HomeFragment();
        orderFragment=new OrderFragment();
        companyFragment=new CompanyFragment();
        mineFragment=new MineFragment();
        fragments.add(homeFragment);
        fragments.add(orderFragment);
        fragments.add(companyFragment);
        fragments.add(mineFragment);
        return fragments;
    }

    @Override
    protected View getCenterView() {
        LinearLayout centerView= (LinearLayout) LayoutInflater.from(mActivity).inflate(R.layout.centerview,null);
        centerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startAty(LogisticsActivity.class);
            }
        });
        return centerView;
    }
}
